<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CSS 3D变换示例</title>
    <style>
        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }

        body {
            font-family: Arial, sans-serif;
            line-height: 1.6;
            padding: 2rem;
            background-color: #f0f0f0;
            perspective: 1000px;
        }

        .container {
            max-width: 800px;
            margin: 0 auto;
        }

        h1 {
            text-align: center;
            margin-bottom: 2rem;
            color: #333;
        }

        .example-section {
            background: white;
            padding: 2rem;
            margin-bottom: 2rem;
            border-radius: 8px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }

        h2 {
            margin-bottom: 1rem;
            color: #444;
        }

        /* 1. 3D卡片翻转 */
        .flip-card {
            width: 200px;
            height: 300px;
            perspective: 1000px;
            margin: 20px auto;
        }

        .flip-card-inner {
            position: relative;
            width: 100%;
            height: 100%;
            text-align: center;
            transition: transform 0.8s;
            transform-style: preserve-3d;
            cursor: pointer;
        }

        .flip-card:hover .flip-card-inner {
            transform: rotateY(180deg);
        }

        .flip-card-front, .flip-card-back {
            position: absolute;
            width: 100%;
            height: 100%;
            backface-visibility: hidden;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 8px;
        }

        .flip-card-front {
            background-color: #2196F3;
            color: white;
        }

        .flip-card-back {
            background-color: #4CAF50;
            color: white;
            transform: rotateY(180deg);
        }

        /* 2. 3D旋转立方体 */
        .cube-container {
            width: 200px;
            height: 200px;
            margin: 50px auto;
            perspective: 1000px;
        }

        .cube {
            width: 100%;
            height: 100%;
            position: relative;
            transform-style: preserve-3d;
            animation: rotate 10s infinite linear;
        }

        @keyframes rotate {
            from { transform: rotateX(0) rotateY(0); }
            to { transform: rotateX(360deg) rotateY(360deg); }
        }

        .cube-face {
            position: absolute;
            width: 200px;
            height: 200px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 20px;
            color: white;
            border: 2px solid rgba(255,255,255,0.3);
        }

        .front  { transform: translateZ(100px); background: rgba(255, 0, 0, 0.8); }
        .back   { transform: translateZ(-100px) rotateY(180deg); background: rgba(0, 255, 0, 0.8); }
        .right  { transform: translateX(100px) rotateY(90deg); background: rgba(0, 0, 255, 0.8); }
        .left   { transform: translateX(-100px) rotateY(-90deg); background: rgba(255, 255, 0, 0.8); }
        .top    { transform: translateY(-100px) rotateX(90deg); background: rgba(255, 0, 255, 0.8); }
        .bottom { transform: translateY(100px) rotateX(-90deg); background: rgba(0, 255, 255, 0.8); }

        /* 3. 3D轮播图 */
        .carousel-container {
            width: 300px;
            height: 200px;
            margin: 50px auto;
            perspective: 1000px;
        }

        .carousel {
            width: 100%;
            height: 100%;
            position: relative;
            transform-style: preserve-3d;
            animation: carousel 10s infinite linear;
        }

        @keyframes carousel {
            from { transform: rotateY(0); }
            to { transform: rotateY(360deg); }
        }

        .carousel-item {
            position: absolute;
            width: 280px;
            height: 180px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 24px;
            color: white;
            border-radius: 8px;
            box-shadow: 0 0 10px rgba(0,0,0,0.3);
        }

        .carousel-item:nth-child(1) { transform: rotateY(0) translateZ(200px); background: #ff6b6b; }
        .carousel-item:nth-child(2) { transform: rotateY(72deg) translateZ(200px); background: #4ecdc4; }
        .carousel-item:nth-child(3) { transform: rotateY(144deg) translateZ(200px); background: #45b7d1; }
        .carousel-item:nth-child(4) { transform: rotateY(216deg) translateZ(200px); background: #96ceb4; }
        .carousel-item:nth-child(5) { transform: rotateY(288deg) translateZ(200px); background: #d4a5a5; }
    </style>
</head>
<body>
    <div class="container">
        <h1>CSS 3D变换示例</h1>

        <div class="example-section">
            <h2>1. 3D卡片翻转</h2>
            <p>悬停查看卡片背面：</p>
            <div class="flip-card">
                <div class="flip-card-inner">
                    <div class="flip-card-front">
                        <h3>正面内容</h3>
                    </div>
                    <div class="flip-card-back">
                        <h3>背面内容</h3>
                    </div>
                </div>
            </div>
        </div>

        <div class="example-section">
            <h2>2. 3D旋转立方体</h2>
            <p>自动旋转的3D立方体：</p>
            <div class="cube-container">
                <div class="cube">
                    <div class="cube-face front">前</div>
                    <div class="cube-face back">后</div>
                    <div class="cube-face right">右</div>
                    <div class="cube-face left">左</div>
                    <div class="cube-face top">上</div>
                    <div class="cube-face bottom">下</div>
                </div>
            </div>
        </div>

        <div class="example-section">
            <h2>3. 3D轮播图</h2>
            <p>3D旋转的轮播效果：</p>
            <div class="carousel-container">
                <div class="carousel">
                    <div class="carousel-item">1</div>
                    <div class="carousel-item">2</div>
                    <div class="carousel-item">3</div>
                    <div class="carousel-item">4</div>
                    <div class="carousel-item">5</div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>
